import { Component } from 'react';
import { Arrow,BalanceList,TodoList,Underway,GoodJob,Question,Service,LocationO } from '@react-vant/icons';
import './index.less'
import { getUserInfo } from '../../api/user';
import MyLoading from '../../components/loading'
import WithRouter from '../../router/withRouter';
class Mine extends Component {
    state={
        info:null
    }
    render() {
        let {info} = this.state;
        return (
           <div>
            {info && (
                  <div className='Mine'>
                  <div className="bg">
                      <div className="userInfo">
                          <div className="usermsg">
                              <div className="user_img">
                                  <img src={info.avatar} alt="" onClick={()=>{
                                    this.props.router.navigate('/userprofile')
                                  }}/>
                              </div>
                              <div className="user_info">
                                  <div className="info_name">
                                  {info.nickname}  <span className="pt">{info.vipName}</span>
                                  </div>
                                  <div>{info.phone}</div>
                              </div>
                          </div>
                          <div className="usercontent">
                              <div className="content_item">
                                  <div className="one">{info.nowMoney}</div>
                                  <div className="two">余额</div>
                              </div>
                              <div className="content_item">
                                  <div className="one">{info.integral}</div>
                                  <div className="two">积分</div>
                              </div>
                              <div className="content_item">
                                  <div className="one">{info.couponCount}</div>
                                  <div className="two">优惠券</div>
                              </div>
                              <div className="content_item">
                                  <div className="one">{info.collectCount}</div>
                                  <div className="two">收藏</div>
                              </div>
                          </div>
                      </div>
                  </div>
                  <div className="order">
                      <div className="orderTitle">
                          订单中心 <span>查看全部 <Arrow  /></span>
                      </div>
                      <div className="orderList">
                          <div className="order_item">
                              <TodoList fontSize='30' color='#e93323'/>
                              <div className="ordername">待付款</div>
                          </div>
                          <div className="order_item">
                               <BalanceList  fontSize='30' color='#e93323'/>
                              <div className="ordername">代发货</div>
                          </div>
                          <div className="order_item">
                          <Underway fontSize='30' color='#e93323' />
                              <div className="ordername">待收货</div>
                          </div>
                          <div className="order_item">
                          <GoodJob fontSize='30' color='#e93323' />
                              <div className="ordername">待评价</div>
                          </div>
                          <div className="order_item">
                          <Question  fontSize='30' color='#e93323'/>
                              <div className="ordername">退货/售后</div>
                          </div>
                      </div>
                  </div>
                  <div className="order server">
                      <div className="orderTitle">
                          我的服务 
                      </div>
                      <div className="orderList myserve">
                      <div className="order_item" onClick={()=>{
                        this.props.router.navigate("/address")
                      }}>
                              <LocationO fontSize='30' color='#e93323'/>
                              <div className="ordername">收获地址</div>
                          </div>
                          <div className="order_item cancat" onClick={()=>{
                           window.location.href='https://www14.53kf.com/m.php?cid=72731211&arg=10731211&kf_sign=jc4NjMTY2NI1MTUwMDk4OTk0ODAwMTQ3MjczMTIxMQ%253D%253D&style=1&timeStamp=1677465666438&ucust_id=' 
                          }}>
                              <Service fontSize='30' color='#e93323'/>
                              <div className="ordername">联系客服</div>
                          </div>
                      </div>
                  </div>
              </div>
            )}
            {!info && <MyLoading/>}
           </div>
        )
    }
    async componentDidMount(){
        let res = await getUserInfo();
        console.log(res)
        this.setState({
            info:res.data.data
        })
    }
}
export default WithRouter(Mine)